package com.course.test;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.sql.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

import com.course.safe.MD5;
import com.course.db.*;

public class test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		//User user = new User();
		//user.exeQuery(user.CountSql());
		
		/*
		CourseBasic classbasic = new CourseBasic();
		classbasic.setClassno("10001");
		classbasic.setCourse_span(32);
		classbasic.setCredit(2);
		classbasic.setIntroduction("安徒生的童话");
		classbasic.setName("语文");
		classbasic.setStudents_high(50);
		classbasic.setStudents_low(10);
		classbasic.setTeach_equipments("电教");
		classbasic.setTeach_style("实践");
		classbasic.setTest_style("考试");
		classbasic.setType("人文");
		
		if(classbasic.add())
			System.out.println("Ok!");
		else
			System.out.println("No!");
		
		System.out.println(classbasic.lastid());
		*/
		

	       //resultSet.next(); 
	      // Long id = resultSet.getLong(1); 
	       System.out.println(Double.parseDouble("4.5"));
	   
	       
			
		/*
		MD5 oMD5 = new MD5();
		String psw="student";
		System.out.println(oMD5.getMD5ofStr(psw));
		
		Teacher teacher = new Teacher();
		String strSql = "select user_id , teacher_no from basic_teacherss";
		//teacher.setStrSql();
		ResultSet courseRs = teacher.exeQuery(strSql);
		
		List< Hashtable<String, String> > waitcheckList = new ArrayList< Hashtable<String, String> >();
		try{
			String value="";
			ResultSetMetaData courseRsMd = courseRs.getMetaData();
			int cols = courseRsMd.getColumnCount();
			while (courseRs.next())
			{
				Hashtable<String, String> hash = new Hashtable<String, String>();
				for (int i = 1; i <= cols; i++) {	
					String field = (String) (courseRsMd.getColumnName(i));
					int fieldtype = courseRsMd.getColumnType(i);
					if(fieldtype == java.sql.Types.VARCHAR )
						value = (String) (courseRs.getString(i));
					else if(fieldtype == java.sql.Types.DOUBLE)
						value = (String)(Double.toString(courseRs.getDouble(i)));
					else if(fieldtype == java.sql.Types.INTEGER)
						value = (String)(Integer.toString(courseRs.getInt(i)));
					else if(fieldtype == java.sql.Types.BIGINT)
						value = (String)(Integer.toString(courseRs.getInt(i)));
					else if(fieldtype == java.sql.Types.SMALLINT)
						value = (String)(Integer.toString(courseRs.getInt(i)));
					else if(fieldtype == java.sql.Types.TINYINT)
						value = (String)(Integer.toString(courseRs.getInt(i)));
					else if(fieldtype == java.sql.Types.CHAR)
						value = (String) (courseRs.getString(i));
					else if(fieldtype == java.sql.Types.DATE)
						value = (String) (courseRs.getDate(i).toString());
					
					if (value == null)
						value = "";
					hash.put(field, value);
					System.out.println("field:"+field+" value:"+value);
				}
				waitcheckList.add(hash);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		//User user = new User();
		Iterator<Hashtable<String, String>> course_it = waitcheckList.iterator();
		while(course_it.hasNext())
		{
			Hashtable<String, String> course_hash  = course_it.next();

			//String sql = "update user set password='"+oMD5.getMD5ofStr(course_hash.get("teacher_no"))+"' where Id="+course_hash.get("user_id");
			String sql = "insert into user(Id,name,password,type) values("+course_hash.get("user_id")+","+course_hash.get("teacher_no")+","+oMD5.getMD5ofStr(course_hash.get("teacher_no"))+",'teacher')";
			teacher.exeSql(sql);
		}
		*/
	       
	       /*
	       System.out.println("start load file-------------------------");
			try{
			InputStream is = new FileInputStream("E:/高一高二名单.xls");//创建输入

			jxl.Workbook rwb = Workbook.getWorkbook(is);
			for(int j=0; j<3; j++)
			{
			Sheet rs = rwb.getSheet(j); //读取第一个sheet
			int colNum=rs.getColumns();//列数
			int rowNum=rs.getRows();//行数

			System.out.println("colNum rowNum------------------"+rowNum+","+colNum);
			
			Student student = new Student();
			User user = new User();
			
			
			MD5 oMD5 = new MD5();
			for(int i=1; i<rowNum; i++)
			{
				Cell c = rs.getCell(0, i);
				String grade = c.getContents();
				
				c = rs.getCell(1, i);
				String name = c.getContents();

				c = rs.getCell(2, i);
				String no = c.getContents();

				user.setName(no);
				user.setPassword(oMD5.getMD5ofStr(no));
				user.setType("student");
				user.add();
				
				student.setName(name);
				student.setGrade(grade);
				student.setNo(no);
				student.setUser_id(user.lastid());
				student.add();
				
			}
			
			}
			}catch(Exception e)
			{
				e.printStackTrace();
			}*/
	       
	       ChooseCourse choosecourse = new ChooseCourse();
	       choosecourse.type1_course_num(4);
	}
	

}
